package game.web.struts.json;

import java.util.ArrayList;
import java.util.List;


public class BaseJson<T> {
	List<T> rows = new ArrayList();

	private int page = 0;
	private int rowNum = 0;
	private int records = 0;
	private int total = 0;

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}


	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}


	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		List<T> temp = new ArrayList();
		for(int i=rowNum*(page-1);i<records;i++)
		{
			temp.add(rows.get(i));
		}
		this.rows = temp;
	}

	public int getRecords() {
		return records;
	}

	public void setRecords(int records) {
		this.rowNum = 20;
		this.records = records;
		this.total = records>(records/rowNum)*rowNum?records/rowNum+1:records/rowNum; //页面数 
		System.err.println(total);
	}

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}
}
